package net.lanelife.casino.caipiao.entity;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.EnumType;
import javax.persistence.Enumerated;
import javax.persistence.Index;
import javax.persistence.Table;

import net.lanelife.casino.caipiao.entity.support.UserRelationEntity;
import net.lanelife.casino.common.entity.annotation.Checked;
import net.lanelife.casino.common.utils.BillNoUtils;

import org.hibernate.annotations.DynamicInsert;
import org.hibernate.annotations.DynamicUpdate;
import org.hibernate.annotations.Type;
import org.joda.time.DateTime;

/**
 * 投注记录
 * 
 * @author Lane
 * 
 */
@Entity
@DynamicInsert
@DynamicUpdate
@Table(name = "TB_BET_RECORD", indexes = { 
	@Index(name = "IDX_BILLNO", columnList = "BILLNO"),
	@Index(name = "IDX_GAME_ID", columnList = "GAME_ID"),
	@Index(name = "IDX_GAME_NAME", columnList = "GAME_NAME"),
	@Index(name = "IDX_ISSUE", columnList = "ISSUE"),
	@Index(name = "IDX_BET_TIME", columnList = "BET_TIME"),
	@Index(name = "IDX_USER_ID", columnList = "USER_ID"),
	@Index(name = "IDX_USER_NAME", columnList = "USER_NAME"),
	@Index(name = "IDX_FLOOR", columnList = "FLOOR"),
	@Index(name = "IDX_PATH", columnList = "PATH"),
	@Index(name = "IDX_PARENT_ID", columnList = "PARENT_ID"),
	@Index(name = "IDX_PARENT_NAME", columnList = "PARENT_NAME")
})
public class BetRecord extends UserRelationEntity<Integer> {

	private static final long serialVersionUID = -6378188431615185271L;

	/**
	 * 单号
	 */
	@Checked
	@Column(name = "BILLNO", length = 24, nullable = false)
	private String billNo = BillNoUtils.generateBillNo(BillNoUtils.PREFIX_TZ);

	/**
	 * 彩种ID
	 */
	@Checked
	@Column(name = "GAME_ID", nullable = false)
	private Integer gameId;

	/**
	 * 彩种名称 - 重庆时时彩
	 */
	@Checked
	@Column(name = "GAME_NAME", length = 10, nullable = false)
	private String gameName;

	/**
	 * 玩法分类ID
	 */
	@Checked
	@Column(name = "PLAY_KIND_ID", nullable = false)
	private Integer playKindId;

	/**
	 * 玩法分类名称 - 三星
	 */
	@Checked
	@Column(name = "PLAY_KIND_NAME", length = 10, nullable = false)
	private String playKindName;

	/**
	 * 玩法ID
	 */
	@Checked
	@Column(name = "PLAY_TYPE_ID", nullable = false)
	private Integer playTypeId;

	/**
	 * 玩法名称 - 前三直选单式
	 */
	@Checked
	@Column(name = "PLAY_TYPE_NAME", length = 10, nullable = false)
	private String playTypeName;

	/**
	 * 期号
	 */
	@Checked
	@Column(name = "ISSUE", length = 15, nullable = false)
	private String issue;

	/**
	 * 投注时间
	 */
	@Column(name = "BET_TIME", nullable = false)
	@Type(type = "net.lanelife.casino.common.entity.usertype.PersistentDateTimeAsMillisLong")
	private DateTime betTime = DateTime.now();

	/**
	 * 投注注数 - 2
	 */
	@Checked
	@Column(name = "BET_COUNT", nullable = false)
	private Integer betCount;

	/**
	 * 单注金额 - 2.00
	 */
	@Checked
	@Column(name = "BET_AMOUNT", nullable = false)
	private Double betAmount;

	/**
	 * 投注总额 - 4.00
	 */
	@Checked
	@Column(name = "BET_TOTAL", nullable = false)
	private Double betTotal;

	/**
	 * 投注号码 - 0|0|0,1
	 */
	@Checked
	@Column(name = "BET_NUMBER", nullable = false)
	private String betNumber;

	/**
	 * 投注位 - 0,1,2,3,4
	 */
	@Checked
	@Column(name = "BET_DIGITS", length = 10, nullable = false)
	private String betDigits;

	/**
	 * 赔率 - 900.00
	 */
	@Checked
	@Column(name = "ODDS", nullable = false)
	private Double odds;

	/**
	 * 奖金 - 1800.00
	 */
	@Checked
	@Column(name = "BONUS", nullable = false)
	private Double bonus;

	/**
	 * 所选返点 - 6.5
	 */
	@Checked
	@Column(name = "REBATE_POINT", nullable = false)
	private Float rebatePoint;

	/**
	 * 上级返点列表 - 1:7.5|2:7.0|3:6.5
	 */
	@Checked
	@Column(name = "REBATE_POINTS", length = 400, nullable = false)
	private String rebatePoints;

	/**
	 * 中奖状态
	 */
	@Checked
	@Enumerated(EnumType.ORDINAL)
	@Column(name = "WIN_STATUS", nullable = false)
	private WinStatus winStatus = WinStatus.UNKNOWN;

	/**
	 * 中奖注数
	 */
	@Checked
	@Column(name = "WIN_COUNT", nullable = false)
	private Integer winCount = 0;

	/**
	 * 中奖金额
	 */
	@Checked
	@Column(name = "WIN_AMOUNT", nullable = false)
	private Double winAmount = 0D;

	/**
	 * 派奖状态
	 */
	@Checked
	@Enumerated(EnumType.ORDINAL)
	@Column(name = "AWARD_STATUS", nullable = false)
	private AwardStatus awardStatus = AwardStatus.UNAWARD;

	/**
	 * 派奖时间
	 */
	@Column(name = "AWARD_TIME")
	@Type(type = "net.lanelife.casino.common.entity.usertype.PersistentDateTimeAsMillisLong")
	private DateTime awardTime;

	/**
	 * 订单状态
	 */
	@Checked
	@Enumerated(EnumType.ORDINAL)
	@Column(name = "ORDER_STATUS", nullable = false)
	private OrderStatus orderStatus = OrderStatus.NORMAL;

	/**
	 * 投注方式
	 */
	@Checked
	@Enumerated(EnumType.ORDINAL)
	@Column(name = "BET_WAY", nullable = false)
	private BetWay betWay;

	/**
	 * 追号记录ID
	 */
	@Checked
	@Column(name = "CHASE_RECORD_ID", nullable = false)
	private Integer chaseRecordId = 0;

	/**
	 * 追号期号ID
	 */
	@Checked
	@Column(name = "CHASE_ISSUE_ID", nullable = false)
	private Integer chaseIssueId = 0;

	/**
	 * 追号号码ID
	 */
	@Checked
	@Column(name = "CHASE_NUMBER_ID", nullable = false)
	private Integer chaseNumberId = 0;

	/**
	 * 开奖号码
	 */
	@Checked
	@Column(name = "LOTTERY_NUMBER", nullable = false)
	private String lotteryNumber = "";

	/**
	 * 投注返点派发状态
	 */
	@Checked
	@Enumerated(EnumType.ORDINAL)
	@Column(name = "BET_REBATE_STATUS", nullable = false)
	private RebateStatus betRebateStatus = RebateStatus.NOTGIVE;

	/**
	 * 代理返点派发状态
	 */
	@Checked
	@Enumerated(EnumType.ORDINAL)
	@Column(name = "AGENT_REBATE_STATUS", nullable = false)
	private RebateStatus agentRebateStatus = RebateStatus.NOTGIVE;

	/**
	 * 中奖状态
	 */
	public static enum WinStatus {
		/**
		 * 未开奖
		 */
		UNKNOWN,
		/**
		 * 赢
		 */
		WIN,
		/**
		 * 输
		 */
		LOSE
	}

	/**
	 * 派奖状态
	 */
	public static enum AwardStatus {
		/**
		 * 未派奖
		 */
		UNAWARD,
		/**
		 * 已派奖
		 */
		AWARDED
	}

	/**
	 * 订单状态
	 */
	public static enum OrderStatus {
		/**
		 * 正常
		 */
		NORMAL,
		/**
		 * 撤单
		 */
		CANNEL
	}

	/**
	 * 投注方式
	 */
	public static enum BetWay {
		/**
		 * 普通投注
		 */
		NORMAL,
		/**
		 * 追号投注
		 */
		CHASE
	}

	/**
	 * 返点发放状态
	 */
	public static enum RebateStatus {
		/**
		 * 已发放
		 */
		GAVE,
		/**
		 * 未发放
		 */
		NOTGIVE
	}
	
	public BetRecord(User user) {
		super(user);
	}

	public String getBillNo() {
		return billNo;
	}

	public void setBillNo(String billNo) {
		this.billNo = billNo;
	}

	public Integer getGameId() {
		return gameId;
	}

	public void setGameId(Integer gameId) {
		this.gameId = gameId;
	}

	public String getGameName() {
		return gameName;
	}

	public void setGameName(String gameName) {
		this.gameName = gameName;
	}

	public Integer getPlayKindId() {
		return playKindId;
	}

	public void setPlayKindId(Integer playKindId) {
		this.playKindId = playKindId;
	}

	public String getPlayKindName() {
		return playKindName;
	}

	public void setPlayKindName(String playKindName) {
		this.playKindName = playKindName;
	}

	public Integer getPlayTypeId() {
		return playTypeId;
	}

	public void setPlayTypeId(Integer playTypeId) {
		this.playTypeId = playTypeId;
	}

	public String getPlayTypeName() {
		return playTypeName;
	}

	public void setPlayTypeName(String playTypeName) {
		this.playTypeName = playTypeName;
	}

	public String getIssue() {
		return issue;
	}

	public void setIssue(String issue) {
		this.issue = issue;
	}

	public DateTime getBetTime() {
		return betTime;
	}

	public void setBetTime(DateTime betTime) {
		this.betTime = betTime;
	}

	public Integer getBetCount() {
		return betCount;
	}

	public void setBetCount(Integer betCount) {
		this.betCount = betCount;
	}

	public Double getBetAmount() {
		return betAmount;
	}

	public void setBetAmount(Double betAmount) {
		this.betAmount = betAmount;
	}

	public Double getBetTotal() {
		return betTotal;
	}

	public void setBetTotal(Double betTotal) {
		this.betTotal = betTotal;
	}

	public String getBetNumber() {
		return betNumber;
	}

	public void setBetNumber(String betNumber) {
		this.betNumber = betNumber;
	}

	public String getBetDigits() {
		return betDigits;
	}

	public void setBetDigits(String betDigits) {
		this.betDigits = betDigits;
	}

	public Double getOdds() {
		return odds;
	}

	public void setOdds(Double odds) {
		this.odds = odds;
	}

	public Double getBonus() {
		return bonus;
	}

	public void setBonus(Double bonus) {
		this.bonus = bonus;
	}

	public Float getRebatePoint() {
		return rebatePoint;
	}

	public void setRebatePoint(Float rebatePoint) {
		this.rebatePoint = rebatePoint;
	}

	public String getRebatePoints() {
		return rebatePoints;
	}

	public void setRebatePoints(String rebatePoints) {
		this.rebatePoints = rebatePoints;
	}

	public WinStatus getWinStatus() {
		return winStatus;
	}

	public void setWinStatus(WinStatus winStatus) {
		this.winStatus = winStatus;
	}

	public Integer getWinCount() {
		return winCount;
	}

	public void setWinCount(Integer winCount) {
		this.winCount = winCount;
	}

	public Double getWinAmount() {
		return winAmount;
	}

	public void setWinAmount(Double winAmount) {
		this.winAmount = winAmount;
	}

	public AwardStatus getAwardStatus() {
		return awardStatus;
	}

	public void setAwardStatus(AwardStatus awardStatus) {
		this.awardStatus = awardStatus;
	}

	public DateTime getAwardTime() {
		return awardTime;
	}

	public void setAwardTime(DateTime awardTime) {
		this.awardTime = awardTime;
	}

	public OrderStatus getOrderStatus() {
		return orderStatus;
	}

	public void setOrderStatus(OrderStatus orderStatus) {
		this.orderStatus = orderStatus;
	}

	public BetWay getBetWay() {
		return betWay;
	}

	public void setBetWay(BetWay betWay) {
		this.betWay = betWay;
	}

	public Integer getChaseRecordId() {
		return chaseRecordId;
	}

	public void setChaseRecordId(Integer chaseRecordId) {
		this.chaseRecordId = chaseRecordId;
	}

	public Integer getChaseIssueId() {
		return chaseIssueId;
	}

	public void setChaseIssueId(Integer chaseIssueId) {
		this.chaseIssueId = chaseIssueId;
	}

	public Integer getChaseNumberId() {
		return chaseNumberId;
	}

	public void setChaseNumberId(Integer chaseNumberId) {
		this.chaseNumberId = chaseNumberId;
	}

	public String getLotteryNumber() {
		return lotteryNumber;
	}

	public void setLotteryNumber(String lotteryNumber) {
		this.lotteryNumber = lotteryNumber;
	}

	public RebateStatus getBetRebateStatus() {
		return betRebateStatus;
	}

	public void setBetRebateStatus(RebateStatus betRebateStatus) {
		this.betRebateStatus = betRebateStatus;
	}

	public RebateStatus getAgentRebateStatus() {
		return agentRebateStatus;
	}

	public void setAgentRebateStatus(RebateStatus agentRebateStatus) {
		this.agentRebateStatus = agentRebateStatus;
	}

}
